package search;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class SearchAttribute {
	public static final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMMM dd, yyyy", Locale.ENGLISH);
	private String value;
	private int type;

	public SearchAttribute(int type, String value) {		
		this.type = type;
		this.value = value;
	}

	public int getType() {
		return type;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
	@Override
	public String toString() {		
		return type+" "+value;
	}
	
	public boolean isInt(){
		try{
			Integer.parseInt(value);
			return true;
		} catch(NumberFormatException e){
			return false;
		}
	}
	
	public boolean isDate(){
		try{
			dateFormat.parse(value);
			return true;
		} catch(ParseException e){
			return false;
		}
	}
	
	public boolean isRegularText(){
		return !isDate() && !isInt();
	}
}
